package java_DesignPattern.StructuralPattern.FacadePattern;

/**
 * 外观类
 */
public class Facade {

    private Light light;
    private TV tv;
    private KongTiao kongTiao;

    public Facade() {
        light = new Light();
        tv = new TV();
        kongTiao = new KongTiao();
    }

    /**
     * 打开所有设备
     */
    private void on() {
        light.on();
        tv.on();
        kongTiao.on();
    }

    /**
     * 关闭所有设备
     */
    private void off() {
        light.off();
        tv.off();
        kongTiao.off();
    }

    /**
     * 控制设备
     */
    public void play(String message) {

        if (message.equals("on")) {
            on();
        } else if (message.equals("off")) {
            off();
        } else {
            System.out.println("未知指令");
        }
    }
}
